home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2008 January / Cybermycha 1_2008.iso / Data.cab / _E85E47ED6D9348128DB30B85844309A2 < prev    next >
Encoding:
Text File  |  2004-05-27  |  2.0 KB  |  102 lines

  1.  
  2. regc(2, "COMBINED_XFORM")
  3. regc(6, "MODEL_XFORM")
  4.  
  5. regc(12, "FOG_PARAMS")
  6.  
  7. regc(13, "CAMERA_POS_MS")
  8. regcn(14, "DIRECTIONAL_DIR_MS", 0)
  9.  
  10. regc(20, "TEXTURE2_XFORM")
  11. regc(24, "TEXTURE3_XFORM")
  12.  
  13. regc4f(30, 0.0, 0.0, 0.0, %sunvisibility)
  14.  
  15. // ------------ c40 - c60 reserved
  16. !include("vs_spot_consts.inc")
  17.  
  18. vshader("
  19.  
  20. #define point        v0
  21. #define normal        v1
  22. #define tangent        v2
  23. #define tcoord        v3
  24.  
  25. #define fogp    c12
  26. #define cpos    c13
  27. #define ldir    c14
  28.  
  29.     vs_1_1
  30.  
  31. #include    <cardef.h>
  32. #include    <fog.inc>
  33.  
  34.     def c0, SPECULARPOW, 0, 0, 0
  35.     def    c1, 1, 0, 0, FRESNELSCALE
  36.  
  37.     dcl_position    point
  38.     dcl_normal        normal
  39.     dcl_tangent        tangent
  40.     dcl_texcoord    tcoord
  41.  
  42.     ; output position
  43.     m4x4    oPos, point, c2
  44.  
  45.     ; E in model space
  46.     add r2, cpos, -point
  47. /*    nie zmiescilo sie w ps
  48.       ; fresnel
  49.     dp3 r6.w, r2, r2
  50.     rsq r6.w, r6.w
  51.     mul r6.xyz, r2, r6.w
  52.  
  53.     dp3    r6.w, r6, normal
  54.     mad r6.w, r6.w, -r6.w, c1.x  // -dot(E, N)*dot(E, N)+1 = 1- pow(dot(E, N),2)
  55.     mul    r6.w, r6.w, r6.w        //f^2
  56.     ; output fresnel
  57.     mul oD1.w, r6.w, c1.w
  58. */
  59.     ; normalize E
  60.     dp3 r2.w, r2, r2
  61.     rsq r2.w, r2.w
  62.     mul r2.xyz, r2, r2.w
  63.  
  64.     ; reflect E
  65.     dp3 r5.w, r2, normal
  66.     add r6.w, r5.w, r5.w
  67.     mad r6.xyz, normal, r6.w, -r2 // dot(E, N)*2 *N - E
  68.  
  69.     ; output cubemap
  70.     m3x3    oT3, -r6, c6
  71.  
  72.     dp3        r4.x, normal, ldir        ; diffuse N*L
  73.     dp3        r4.y, ldir, r6        ; specular L*E
  74.     mov        r4.w, c0.x              ; specular pow
  75.     lit        r3, r4
  76.  
  77.     ; output diffuse
  78.     mov        oD0.w, r3.y   //  sun
  79.     ; output specular
  80.     mul        oD1, r3.z, c30.w    //sunvisibility
  81.  
  82. ;------------------------------------------
  83. // spot light
  84. // used r0 - r2
  85. #if VS_SPOTLIGHTS
  86. #include <vs_spot_func.inc>
  87. #endif
  88. ;----------------------------
  89.     ; output texcoords
  90.     mov        oT0, tcoord           // color
  91.     mov     oT1, tcoord        // dirt
  92.  
  93.     ; terrain lightmap texgen (from model space)
  94.     dp4        oT2.x, point, c20
  95.     dp4        oT2.y, point, c21
  96.  
  97.     ; calc fog
  98.        dp4    r0.x, point, c4
  99.        FOG(r0.x, fogp, r10)
  100. ")
  101.  
  102.